<!DOCTYPE html>
<!--suppress ThymeleafVariablesResolveInspection-->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Responsive Admin Dashboard Template">
    <meta name="keywords" content="admin,dashboard">
    <meta name="author" content="skcats">
    <title></title>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all" />
    <link th:href="@{/assets/plugins/bootstrap/css/bootstrap.min.css}" rel="stylesheet">
    <link th:href="@{/assets/plugins/font-awesome/css/font-awesome.min.css}" rel="stylesheet">
    <link th:href="@{/assets/css/custom.css}" rel="stylesheet">
</head>
<style>
    .layui-table-page {
        text-align: center;
    }

    .utable .layui-laypage .layui-laypage-curr .layui-laypage-em {
        background-color: #1E9FFF;
    }
    .layui-input-inline{margin-left: 50px;}
    .layui-form-item{margin-top: 20px;}
    .layui-form-label{width: 80px;}
</style>
<body>
<script id="toolbarDemo" type="text/html">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="adjustdorm"><i class="layui-icon">&#xe691;</i>调整宿舍</button>
        <button class="layui-btn layui-btn-sm" lay-event="moveoutdorm"><i class="layui-icon">&#xe683;</i>搬离宿舍(毕业生)</button>
        <button class="layui-btn layui-btn-sm" lay-event="adjustclass"><i class="layui-icon">&#xe691;</i>调整班级</button>
        <button class="layui-btn layui-btn-sm" lay-event="adjustroll"><i class="layui-icon">&#xe691;</i>调整学籍</button>
        <button class="layui-btn layui-btn-sm" lay-event="sendcomputer"><i class="layui-icon">&#xe67f;</i>是否送电脑</button>
        <button class="layui-btn layui-btn-sm" lay-event="receivecomputer"><i class="layui-icon">&#xe67f;</i>是否领用电脑</button>
        <button class="layui-btn layui-btn-sm" lay-event="enjoymoney"><i class="layui-icon">&#xe65e;</i>是否享受助学金</button>
        <button class="layui-btn layui-btn-sm" lay-event="setgraduate"><i class="layui-icon">&#xe68f;</i>设置毕业</button>
    </div>

</script>
<!--数据表格样式及附件-->
<script type="text/html" id="bar">
    <a id="edit" class="layui-btn layui-btn-xs" lay-event="edit">
        <i class="layui-icon">&#xe642;</i>重置密码
    </a>
    <a class="layui-btn layui-btn-xs" lay-event="ck">
        <i class="layui-icon">&#xe6b2;</i>查看
    </a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">
        <i class="layui-icon">&#x1006;</i>退学
    </a>
</script>
<script type="text/html" id="sexTpl">
    {{#  if(d.emp_sex === '女'){ }}
    <span style="color: #F581B1;">{{ d.emp_sex }}</span>
    {{#  } else { }}
    {{ d.emp_sex }}
    {{#  } }}
</script>


<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>

<script type="text/html" id="toolbar">
    <a class="layui-btn layui-btn-xs" lay-event="add">添加</a>
</script>

<!--搜索栏-->
<from class="layui-form">
    <div class="layui-inline">
        <label class="layui-form-label">学号：</label>
        <div class="layui-input-inline">
            <input type="text" name="stuno" id="stuno" class="layui-input"/>
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">姓名：</label>
        <div class="layui-input-inline">
            <input type="text" name="stuname" id="stuname" class="layui-input"/>
        </div>
    </div>
    <div class="layui-inline">
    <label class="layui-form-label">班级：</label>
    <div class="layui-input-block">
        <select id="clazz" name="clazz" style="height: 35px;width: 120px;">
            <option value="">请选择班级</option>
            <option th:each="sc:${studentclasses}" th:value="${sc.classid}" th:text="${sc.classname}"></option>
        </select>
    </div>
    </div>
    <div class="layui-inline">
        <button id="ck" type="button" class="btn btn-info btn-addon"><i class="fa fa-spin fa-refresh"></i> 查找</button>
        <button id="add" class="layui-btn layui-btn-sm"><i class="layui-icon">&#xe654;</i>新增</button>
    </div>
</from>

<!--数据表格  数据表格使用的是方法渲染-->
<div class="utable">
    <table class="layui-table"
           lay-data="{width:1250,height:400, url:'/stu/studata', page:true, id:'tab',toolbar: '#toolbarDemo' }"
           lay-filter="test">
        <thead>
        <tr>
            <th lay-data="{type: 'radio', fixed: 'left'}"></th>
            <th lay-data="{field:'Studid', width:80, sort: true,hide:true}">学生id</th>
            <th lay-data="{field:'clazz',hide:true}">班级id</th>
            <th lay-data="{field:'huor',hide:true}">宿舍房号id</th>
            <th lay-data="{field:'introduretech',hide:true}">介绍老师</th>

            <th lay-data="{field:'stuno'}">学号</th>
            <th lay-data="{field:'stuname'}">学生姓名</th>
            <th lay-data="{field:'sex'}">性别</th>
            <th lay-data="{field:'age'}">年龄</th>
            <th lay-data="{field:'cardid'}">身份证号</th>
            <th lay-data="{field:'phone'}">学生电话</th>
            <th lay-data="{field:'className'}">班级</th>
            <th lay-data="{field:'huorName'}">宿舍房号</th>
            <th lay-data="{field:'stat'}">学生状态</th>
            <th lay-data="{fixed: 'right', title:'操作', toolbar: '#bar', width:260}"></th>
        </tr>
        </thead>
    </table>
</div>
<div class="layui-tab">
    <ul class="layui-tab-title">
        <li class="layui-this">教育经历</li>
        <li>家庭情况</li>
        <li>在校情况</li>
        <li>答辩总成绩资料</li>
        <li>考试资料</li>
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show"><table id="demo" lay-filter="test1"></table></div>
        <div class="layui-tab-item"><table id="demo1" lay-filter="test2"></table></div>
        <div class="layui-tab-item"><table id="demo2" lay-filter="test3"></table></div>
        <div class="layui-tab-item"><table id="demo3" lay-filter="test4"></table></div>
        <div class="layui-tab-item"><table id="demo4" lay-filter="test5"></table></div>
    </div>
</div>
</body>
<script th:src="@{/js/register/jquery-3.1.0.min.js}"></script>
<script th:src="@{/layui/layui.js}"></script>


<script type="text/javascript" th:inline="none">


    //注意：选项卡 依赖 element 模块，否则无法进行功能性操作
    layui.use('element', function(){
        var element = layui.element;

        //…
    });

    layui.use('table', function () {
        var table = layui.table;
        //模糊
        $("#ck").on('click',function(){
            var stuno=$("#stuno").val();
            var stuname=$("#stuname").val();
            var clazz=$("#clazz").val();
            table.reload('tab', {
                where: { //设定异步数据接口的额外参数，任意设
                    stuno:stuno,
                    stuname:stuname,
                    clazz:clazz
                }
                ,page: {
                    curr: 1 //重新从第 1 页开始
                }
            });


        });
        //监听行单击事件（双击事件为：rowDouble）
        table.on('row(test)', function(obj){
            var data = obj.data;
            table.reload('demo', {
                where: { //设定异步数据接口的额外参数，任意设
                    studid:data.Studid
                }
                ,page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            table.reload('demo1', {
                where: { //设定异步数据接口的额外参数，任意设
                    studid:data.Studid
                }
                ,page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            table.reload('demo2', {
                where: { //设定异步数据接口的额外参数，任意设
                    studid:data.Studid
                }
                ,page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            table.reload('demo3', {
                where: { //设定异步数据接口的额外参数，任意设
                    studid:data.Studid
                }
                ,page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            table.reload('demo4', {
                where: { //设定异步数据接口的额外参数，任意设
                    studid:data.Studid
                }
                ,page: {
                    curr: 1 //重新从第 1 页开始
                }
            });


            //标注选中样式
            obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');
        });


        //点击添加iframe窗方法
        $("#add").on('click',function(){
            //iframe窗
            layer.open({
                type: 2,
                title: '学生新增',
                maxmin: true, //开启最大化最小化按钮
                area: ['1000px', '500px'],
                content: ['/stu/toadd']//这是链接你的页面地址 url
            });
        })

//监听行工具事件
        table.on('tool(test1)', function (obj) {
            var data = obj.data;
            var id = data.studid;
            if (obj.event === 'del') {
                layer.confirm('真的么?', function (index) {
                    obj.del();
                    layer.close(index);
                    $.ajax({
                        url: '/stu/edel',
                        type: 'post',
                        data: {
                            eid:data.eid
                        },
                        dataType: 'text',
                    })
                });
            } else if (obj.event === 'edit') {
                layer.open({
                    type: 2,
                    title: '修改教育经历',
                    maxmin: true,
                    area: ['550px', '250px'],
                    content: ['/stu/toupde?eid='+data.eid]
                });
            }
        })
        //监听行工具事件1
        table.on('tool(test2)', function (obj) {
            var data = obj.data;
            var id = data.studid;
            if (obj.event === 'del') {
                layer.confirm('真的么?', function (index) {
                    obj.del();
                    layer.close(index);
                    $.ajax({
                        url: '/stu/fdel',
                        type: 'post',
                        data: {
                            id:data.id
                        },
                        dataType: 'text',
                    })
                });
            } else if (obj.event === 'edit') {
                layer.open({
                    type: 2,
                    title: '修改家庭情况',
                    maxmin: true,
                    area: ['550px', '250px'],
                    content: ['/stu/toupdf?id='+data.id]
                });
            }
        })
        //监听行工具事件2
        table.on('tool(test3)', function (obj) {
            var data = obj.data;
            var id = data.studid;
            if (obj.event === 'del') {
                layer.confirm('真的么?', function (index) {
                    obj.del();
                    layer.close(index);
                    $.ajax({
                        url: '/stu/adel',
                        type: 'post',
                        data: {
                            id:data.id
                        },
                        dataType: 'text',
                    })
                });
            } else if (obj.event === 'edit') {
                layer.open({
                    type: 2,
                    title: '修改家庭情况',
                    maxmin: true,
                    area: ['550px', '250px'],
                    content: ['/stu/toupda?id='+data.id]
                });
            }
        })

        //监听行工具事件3
        table.on('tool(test4)', function (obj) {
            var data = obj.data;
            if (obj.event === 'del') {
                layer.confirm('真的么?', function (index) {
                    obj.del();
                    layer.close(index);
                    $.ajax({
                        url: '/stu/Stureplydel',
                        type: 'post',
                        data: {
                            srid:data.srid
                        },
                        dataType: 'text',
                    })
                });
            } else if (obj.event === 'edit') {
                layer.open({
                    type: 2,
                    title: '修改学生答辩',
                    maxmin: true,
                    area: ['550px', '250px'],
                    content: ['/stu/toupdStureply?srid='+data.srid]
                });
            }
        })

        //监听行工具事件4
        table.on('tool(test5)', function (obj) {
            var data = obj.data;
            if (obj.event === 'del') {
                layer.confirm('真的么?', function (index) {
                    obj.del();
                    layer.close(index);
                    $.ajax({
                        url: '/stu/Stuscoredel',
                        type: 'post',
                        data: {
                            ssid:data.ssid
                        },
                        dataType: 'text',
                    })
                });
            } else if (obj.event === 'edit') {
                layer.open({
                    type: 2,
                    title: '修改学生成绩',
                    maxmin: true,
                    area: ['550px', '250px'],
                    content: ['/stu/toupdStuscore?ssid='+data.ssid]
                });
            }
        })


//头工具栏事件
        table.on('toolbar(test1)', function (obj) {
                switch (obj.event) {
                    case 'add':
                        layer.open({
                            type: 2,
                            title: '添加教育经历',
                            maxmin: true,
                            area: ['70%', '70%'],
                            content: ['/stu/toadde']
                        });
                        break;
                }
        });
//头工具栏事件1
        table.on('toolbar(test2)', function (obj) {
            switch (obj.event) {
                case 'add':
                    layer.open({
                        type: 2,
                        title: '添加家庭情况',
                        maxmin: true,
                        area: ['70%', '70%'],
                        content: ['/stu/toaddf']
                    });
                    break;
            }
        });
        //头工具栏事件2
        table.on('toolbar(test3)', function (obj) {
            switch (obj.event) {
                case 'add':
                    layer.open({
                        type: 2,
                        title: '添加在校情况',
                        maxmin: true,
                        area: ['70%', '70%'],
                        content: ['/stu/toadda']
                    });
                    break;
            }
        });


        //头工具栏事件
        table.on('toolbar(test)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);//获取选中行状态
            var data = checkStatus.data;
            //id为学生id
            var id = $.map(data,function(s){return s.Studid;});//获取选中数据的id

            if (data.length === 0){
                layer.msg('请选择学生', { icon: 5, time: 2000 });
            }else{
                switch (obj.event) {
                    //    宿舍调整
                    case 'adjustdorm':
                        layer.open({
                            type: 2,
                            title: '宿舍调整',
                            maxmin: true,
                            area: ['550px', '250px'],
                            content: ['/stu/toadjustdorm?id='+id]
                        });
                        break;
                    //    是否送电脑
                    case 'sendcomputer':
                        layer.open({
                            type: 2,
                            title: '是否送电脑',
                            maxmin: true,
                            area: ['550px', '250px'],
                            content: ['/stu/sendcomputer?id='+id]
                        });
                        break;
                    //    是否享用助学金
                    case 'enjoymoney':
                        layer.open({
                            type: 2,
                            title: '宿舍调整',
                            maxmin: true,
                            area: ['550px', '250px'],
                            content: ['/stu/enjoymoney?id='+id]
                        });
                        break;
                    //    是否领用电脑
                    case 'receivecomputer':
                        layer.open({
                            type: 2,
                            title: '宿舍调整',
                            maxmin: true,
                            area: ['550px', '250px'],
                            content: ['/stu/receivecomputer?id='+id]
                        });
                        break;
                    //    设置毕业 setgraduate
                    case 'setgraduate':
                        $.ajax({
                            url: '/stu/setgraduate?studid='+id,
                            type: 'post',
                            data: {

                            },
                            dataType: 'json',
                            success:function(data){
                                if(data){
                                    alert("成功");
                                    location.reload();
                                }else {
                                    alert("失败");
                                }
                            },
                        })
                        break;
                    //     班级调整
                    case 'adjustclass':
                        layer.open({
                            type:2,
                            title: '班级调整',
                            maxmin: true,
                            area: ['550px', '250px'],
                            content: ['/stu/toadjustclass?id='+id]
                        });
                        break;
                    //    学籍调整
                    case 'adjustroll':
                    layer.open({
                        type:2,
                        title: '学籍调整',
                        maxmin: true,
                        area: ['550px', '250px'],
                        content: ['/stu/toadjustroll?id='+id]
                    });
                    break;
                    //    搬离宿舍
                    case 'moveoutdorm':
                        $.ajax({
                            url: '/stu/updmv?studid='+id,
                            type: 'post',
                            data: {

                            },
                            dataType: 'json',
                            success:function(data){
                                if(data){
                                    alert("成功");
                                    location.reload();
                                }else {
                                    alert("失败");
                                }
                            },
                        })
                    break;
                }
            }
        });
        function ck(id) {
            layer.open({
                type: 2,
                title: '学生新增',
                maxmin: true, //开启最大化最小化按钮
                area: ['100%', '100%'],
                content: ['/stu/select?studid='+id]//这是链接你的页面地址 url
            });
        }
        //监听行工具事件
        table.on('tool(test)', function (obj) {
            var data = obj.data;
            var id = data.Studid;
            //console.log(obj)
            if (obj.event === 'del') {
                layer.confirm('真的么?', function (index) {
                    obj.del();
                    layer.close(index);

                    $.ajax({
                        url: '/stu/del',
                        type: 'post',
                        data: {
                            studid:data.Studid
                        },
                        dataType: 'text',
                    })
                });
            } else if (obj.event === 'edit') {
                $.ajax({
                    url: '/stu/reset',
                    type: 'post',
                    data: {
                        studid:data.Studid
                    },
                    dataType: 'text',
                    success:function(data){
                        if(data){
                            alert("成功");
                            location.reload();
                        }else {
                            alert("失败");
                        }
                    },
                })
            }else if (obj.event === 'ck') {
                ck(id);
            }else if (obj.event === "education"){

            }
        })

        //第一个实例
        table.render({
            elem: '#demo'
            ,height: 300
            ,toolbar: '#toolbar'
            ,url: '/stu/row' //数据接口
            ,cols: [[ //表头
               {field: 'eid', title: 'id', width:80,hide:true}
                ,{field: 'studid', title: '学生id',hide:true}
                ,{field: 'stuname', title: '学生姓名'}
                ,{field: 'school', title: '就读学校'}
                ,{field: 'starttime', title: '开始时间'}
                ,{field: 'endtime', title: '结束时间'}
                ,{fixed: 'right', width:150,title:'操作', align:'center', toolbar: '#barDemo'}
            ]]
        });

        //第二个实例
        table.render({
            elem: '#demo1'
            ,height: 300
            ,toolbar: '#toolbar'
            ,url: '/stu/row1' //数据接口
            ,cols: [[ //表头
                {field: 'id', title: 'id', width:80,hide:true}
                ,{field: 'studid', title: '学生id',hide:true}
                ,{field: 'stuname', title: '学生姓名'}
                ,{field: 'kfname', title: '家长姓名'}
                ,{field: 'relation', title: '与学生关系'}
                ,{field: 'kfphone', title: '家长电话'}
                ,{fixed: 'right', width:150,title:'操作', align:'center', toolbar: '#barDemo'}
            ]]
        });

        //第三个实例
        table.render({
            elem: '#demo2'
            ,height: 300
            ,toolbar: '#toolbar'
            ,url: '/stu/row2' //数据接口
            ,cols: [[ //表头
                {field: 'id', title: 'id', width:80,hide:true}
                ,{field: 'studid', title: '学生id',hide:true}
                ,{field: 'stuname', title: '学生姓名'}
                ,{field: 'caserecord', title: '情况记录'}
                ,{field: 'recordtime', title: '记录时间'}
                ,{field: 'recordson', title: '记录人'}
                ,{field: 'empname', title: '记录人姓名'}
                ,{fixed: 'right', width:150,title:'操作', align:'center', toolbar: '#barDemo'}
            ]]
        });

        //第wu个实例
        table.render({
            elem: '#demo4'
            ,height: 300
            ,url: '/stu/row4' //数据接口
            ,cols: [[ //表头
                {field: 'ssid', title: 'id', width:80,hide:true}
                ,{field: 'scoreid', title: '班级成绩id',hide:true}
                ,{field: 'stuname', title: '学生名称'}
                ,{field: 'courseName', title: '课程名称'}
                ,{field: 'stuid', title: '学生id',hide:true}
                ,{field: 'scure', title: '学生成绩'}
                ,{field: 'rescore', title: '补考成绩'}
                ,{field: 'emp_Name', title: '老师'}
                ,{field: 'remark', title: '备注'}
            ]]
        });

        //第si个实例
        table.render({
            elem: '#demo3'
            ,height: 300
            ,url: '/stu/row3' //数据接口
            ,cols: [[ //表头
                {field: 'srid', title: 'id', width:80,hide:true}
                ,{field: 'replyid', title: '班级id',hide:true}
                ,{field: 'stuid', title: '学生id',hide:true}
                ,{field: 'stuname', title: '学生名称'}
                ,{field: 'score1', title: '功能完善50'}
                ,{field: 'score2', title: '技术难度10'}
                ,{field: 'score3', title: '界面完美10'}
                ,{field: 'score4', title: '回答问题10'}
                ,{field: 'score5', title: '演示方法10'}
                ,{field: 'score6', title: '语言表达10'}
                ,{field: 'score7', title: '总分100'}
                ,{field: 'projectName', title: '项目名称'}
                ,{field: 'emp_Name', title: '老师'}
                ,{field: 'remark', title: '说明'}
            ]]
        });

    })
</script>
</html>